﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Display {
    import flash.events.*;
    import Engine.Managers.*;
    import flash.display.*;
    import Transactions.*;
    import Classes.util.*;

    public class MOTD extends SWFDialog {

        private var m_window:MovieClip;
        private var m_iconLoader:Loader;
        private var m_accept:GenericButton;
        private var m_popGiftDialog:Boolean = false;

        public function MOTD(){
            m_dialogAsset = "assets/dialogs/TI_GenericIconPopUp.swf";
            super(true);
        }
        override protected function onLoadComplete():void{
            this.m_window = (m_loader.content as MovieClip);
            this.m_window.callOutBox_mc.bouquets_mc.visible = false;
            this.m_window.callOutBox_mc.share_bt.visible = false;
            this.m_window.callOutBox_mc.cancel_bt.visible = false;
            this.m_window.callOutBox_mc.callOut_tf.text = ZLoc.t(Global.gameSettings.getString("motdText"), null);
            this.m_accept = new GenericButton(this.m_window.callOutBox_mc.okay_bt, this.onOkClick);
            this.m_accept.text = ZLoc.t("Dialogs", "OkButton");
            this.m_window.callOutBox_mc.close_bt.addEventListener(MouseEvent.CLICK, this.onClose);
            this.m_iconLoader = LoadingManager.load(Global.getAssetURL(Global.gameSettings.getString("motdIcon")), this.onIconLoaded);
            addChild(this.m_window);
            StatsManager.milestone("decoration_md");
        }
        protected function onIconLoaded(_arg1:Event):void{
            var _local2:MovieClip = this.m_window.callOutBox_mc.icon_mc;
            _local2.scaleX = (_local2.scaleY = 1);
            while (_local2.numChildren) {
                _local2.removeChildAt(0);
            };
            var _local3:DisplayObject = this.m_iconLoader.content;
            _local3.x = (-(_local3.width) / 2);
            _local3.y = (-(_local3.height) / 2);
            _local2.addChild(_local3);
        }
        private function onOkClick(_arg1:MouseEvent):void{
            var _local2:String = Global.gameSettings.getString("motdRedirect");
            if (_local2 == "miniMarket"){
                UI.displayMiniMarketDialog(["flowershed", "flowershed_cash"], "motd", "building");
            } else {
                if (_local2 == "giftbox"){
                    this.m_popGiftDialog = true;
                } else {
                    if (_local2 != ""){
                        UI.displayMarketDialog("motd", _local2);
                    };
                };
            };
            this.onClose(_arg1);
        }
        protected function onClose(_arg1:MouseEvent):void{
            this.m_window.callOutBox_mc.okay_bt.removeEventListener(MouseEvent.CLICK, this.onOkClick);
            this.m_window.callOutBox_mc.close_bt.removeEventListener(MouseEvent.CLICK, this.onClose);
            GameTransactionManager.addTransaction(new TSawMOTD());
            if (this.m_popGiftDialog){
                UI.displayGiftDialog();
            };
            _arg1.stopPropagation();
            close();
            StatsManager.milestone("invite_complete");
        }

    }
}//package Display 
